//
//  PMConstraint.h
//  PezMonkey
//
//  Created by Spence DiNicolantonio on 10/30/09.
//  Copyright 2009 Necrosoft. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "PMCore.h"

@class PMBody;


#pragma mark -
#pragma mark Constants / Enums / Types

// Constraint Body Keys
typedef enum _PMConstraintBodyKey {
	PMConstraintBodyKeyA,
	PMConstraintBodyKeyB,
} PMConstraintBodyKey;

// Anchor Type
typedef PMVect PMAnchor;
static inline PMAnchor PMAnchorMake(PMFloat x, PMFloat y) {
	return PMVectMake(x, y);
}

#pragma mark -


@interface PMConstraint : NSObject {
@protected
	// Chipmunk constraint reference
	cpConstraint *constraint;
	
@private
	// Rigid bodies to connect
	PMBody *bodyA;
	PMBody *bodyB;
	
	// User defined data pointer
	id data;
}

@property (nonatomic, retain) PMBody *bodyA;
@property (nonatomic, retain) PMBody *bodyB;
@property (nonatomic, retain) id data;

// Property definitions of getters/setters for data members stored by backend 
// Chipmunk structure. These properties are not synthesized, because their 
// implementations are given explicitly.
@property (assign, readonly) cpConstraint *cpConstraint;
@property (assign) PMFloat maxForce;
@property (assign) PMFloat biasCoef;
@property (assign) PMFloat maxBias;


#pragma mark -
#pragma mark Getters
- (PMBody *)bodyForKey:(PMConstraintBodyKey)bodyKey;


#pragma mark -
#pragma mark Setters
- (void)setBody:(PMBody *)body ForKey:(PMConstraintBodyKey)bodyKey;

@end
